'use strict';

import { DataTypes } from 'sequelize'
import sequelize from '../utils/database.js'
import BaseModel from './BaseModel.js'

class Admin extends BaseModel {
  /**
   * Helper method for defining associations.
   * This method is not a part of Sequelize lifecycle.
   * The `models/index` file will call this method automatically.
   */
  static associate(models) {
    // define association here
  }
}
Admin.init({
  username: {
    type: DataTypes.STRING(100),
    allowNull: false,
    defaultValue: '',
    comment: '用户名'
  },
  account: {
    type: DataTypes.STRING(100),
    unique: true,
    allowNull: false,
    comment: '账号'
  },
  password: {
    type: DataTypes.STRING(128),
    allowNull: false,
    comment: '密码'
  },
  avatar: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '头像'
  },
  mobile: {
    type: DataTypes.CHAR(11),
    allowNull: false,
    defaultValue: ''
  },
  status: {
    type: DataTypes.TINYINT,
    defaultValue: 1,
    comment: '账号状态'
  },
  last_login_time: {
    type: DataTypes.DATE,
    comment: '最后登录时间'
  },
  last_login_ip: {
    type: DataTypes.STRING(100),
    defaultValue: '',
    comment: '最后登录ip'
  },
}, {
  sequelize,
  modelName: 'Admin',
  tableName: 'admin'
});

export default Admin
